const { COMMANDS, hexTransform, ml_parseOneFrameArray, parseArray } = require('./util.js')
const vv = require('vue')


console.log(COMMANDS)
// console.log(hexTransform(4, 0)) // 风速4档
console.log(hexTransform(120, 2, 2)) // 定时，120min
// console.log(hexTransform(3, 1)) // 模式
const windss = hexTransform(120, 2, 2)
console.log(windss, 'windss-------')

let data = {
  miotLinkBaseNativeJs_init: 'uninit'
}
var time_out_num = 150; //30

var flag_outline = true;
var outfunction;
var replaceStr1 = "\"}",
  replaceStr2 = "\"{";
var miotLinkBaseNativeJs_client = null,
  miotLinkBaseNativeJs_puId = null,
  miotLinkBaseNativeJs_modelId = null,
  miotLinkBaseNativeJs_kindId = null,
  miotLinkBaseNativeJs_state = null,
  miotLinkBaseNativeJs_mac = null,
  miotLinkBaseNativeJs_puNickName = null,
  miotLinkBaseNativeJs_cuId = null,
  miotLinkBaseNativeJs_cuName = null,
  miotLinkBaseNativeJs_cuLocation = null,
  miotLinkBaseNativeJs_userdata = null,
  miotLinkBaseNativeJs_language = null,
  miotLinkBaseNativeJs_sequence = null,
  miotLinkBaseNativeJs_init = "uninit",
  miotLinkBaseNativeJs_payRes = "payRes";

//			miotLinkBaseNativeJs_puId = 1000;
//			miotLinkBaseNativeJs_cuId = 103443;

//puId,modelId,kindId,state,province,city //language
// var define_miotlink_init = "{\"code\":\"init\",\"data\":{\"getInitPuData\":\"true\",\"hiddenPluginTitle\":\"true\",\"getLanguage\":\"true\",\"getCuInfo\":\"true\",\"getStatusBarInfo\":\"false\"}}";
var define_miotlink_init = JSON.stringify({
  code: 'init',
  data: {
    getInitPuData: 'true',
    hiddenPluginTitle: 'true',
    getLanguage: 'true',
    getCuInfo: 'true',
    pluginTitle: {
      background: '',
      backAndMoreImg: 'black',
      hiddenTitleName: 'true',
      titleColor: '#666666'
    }
  }
})

console.log(define_miotlink_init, 'define_miotlink_init=======')

var define_miotlink_returnDeviceList = "{\"code\":\"returnDeviceList\"}";
var define_miotlink_code_initRes = "initRes",
  define_miotlink_code_notifyUartData = "notifyUartData",
  define_miotlink_code_notifyDeviceState = "notifyDeviceState",
  define_miotlink_code_getAdditionalInfoRes = "additionalInfoRes",
  define_miotlink_code_goBackRes = "goBackRes";

class basetool{
  /**
  * 构造函数
  * 
  * @param {Object} options 接口参数,key 为必选参数
  */
  constructor() {

  }

  
  /**
   * @description 初始化藍牙
   * @callback initCallback 初始化成功与否回调
   */
  

  initble(initCallback) {
    
  } 

  /**
  * @description 开始扫描
  * @callback devicesCallback - 发现设备回调  
  * @param endTime 扫描结束时间
  */



  

  
 
}

/**
 * ===========================public=================================================================================
 */
 





function connectWebSocket() {
  console.log('coming')
  // if($(".cksetpage").css("opacity") == 1  || $(".ckbianjipage").css("opacity") == 1){
    // doLoadAction("F1F1010100027E");
  // }else{
    doLoadAction("F1F1F000F07E");
  // }
}








// getDeviceData = {}




/**
 * ===============================IOS=============================================================================
 */




/**
 * ==================================android==========================================================================
 */

/** 
 * android
*/





function receiveFromNative_goBackRes() {
  sendToNative_returnDeviceList();
}
function sendToNative_returnDeviceList() {
  console.log(8)
  if (miotLinkBaseNativeJs_client == "Android") {
    miotLinkBaseNativeJs_sendToAndroid(define_miotlink_returnDeviceList);
  } else if (miotLinkBaseNativeJs_client == "IOS") {
    miotLinkBaseNativeJs_sendToIos(define_miotlink_returnDeviceList);
  } else {
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if(isAndroid == true){
      miotLinkBaseNativeJs_sendToAndroid(define_miotlink_returnDeviceList);
    } else if(isiOS == true) {
      miotLinkBaseNativeJs_sendToIos(define_miotlink_returnDeviceList);
    }
  }
}




module.exports = basetool;